home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1471 / clscfile.cls < prev    next >
Encoding:
Text File  |  1997-02-11  |  2.8 KB  |  105 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "clscFileSysItems"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9. Private colData As New Collection
  10.  
  11. 'Requred property (or function)
  12. Public Property Get Item(Index) As clsFileSysItem
  13. Set Item = colData(Index)
  14. End Property
  15.  
  16. 'Requred property (or function)
  17. Public Property Get Count()
  18. Count = colData.Count
  19. End Property
  20.  
  21. Public Sub Add(NewItem As clsFileSysItem)
  22. colData.Add NewItem
  23. End Sub
  24.  
  25. Public Sub Create(strDirPath As String)
  26. Dim fsItem As clsFileSysItem
  27. Dim strTemp As String
  28. Dim strExt As String
  29.  
  30. 'Folders first
  31. strTemp = Dir(strDirPath, vbDirectory)
  32.  
  33. Do While strTemp <> ""
  34.     If strTemp <> "." And strTemp <> ".." Then
  35.         ' Use bitwise comparison to make sure MyName is a directory.
  36.         If (GetAttr(strDirPath & strTemp) And vbDirectory) = vbDirectory Then
  37.             
  38.             Set fsItem = New clsFileSysItem
  39.             
  40.             With fsItem
  41.                 .Name = strTemp
  42.                 .DateModified = FileDateTime(strDirPath & strTemp)
  43.                 .Size = FileLen(strDirPath & strTemp)
  44.                 .strDirPath = strDirPath
  45.                 .Image = "Folder"
  46.             End With
  47.             
  48.             colData.Add fsItem
  49.             
  50.         End If
  51.         
  52.     End If
  53.     strTemp = Dir
  54. Loop
  55.  
  56. For Each fsItem In colData
  57.     
  58.     fsItem.HasChildren = Dir(strDirPath & fsItem.Name & "\") <> ""
  59.     
  60.     If fsItem.HasChildren = False Then
  61.         strTemp = Dir(strDirPath & fsItem.Name & "\", vbDirectory)
  62.         Do While strTemp <> ""
  63.             If strTemp <> "." And strTemp <> ".." Then
  64.                 fsItem.HasChildren = True
  65.             End If
  66.             strTemp = Dir
  67.         Loop
  68.     End If
  69.  
  70. Next
  71.  
  72. 'files now ...
  73. strTemp = Dir(strDirPath)
  74.  
  75. Do While strTemp <> ""
  76.     If strTemp <> "." And strTemp <> ".." Then
  77.         ' Use bitwise comparison to make sure MyName is a directory.
  78.         If (GetAttr(strDirPath & strTemp) And vbDirectory) <> vbDirectory Then
  79.             
  80.             Set fsItem = New clsFileSysItem
  81.             
  82.             With fsItem
  83.                 .Name = strTemp
  84.                 .DateModified = FileDateTime(strDirPath & strTemp)
  85.                 .Size = FileLen(strDirPath & strTemp)
  86.                 .strDirPath = strDirPath
  87.                     strExt = Right(strTemp, 4)
  88.                 If strExt = ".EXE" Or strExt = ".COM" Or strExt = ".BAT" Or strExt = ".DLL" Or strExt = ".SYS" Or strExt = ".VXD" Then
  89.                     .Image = "Program"
  90.                   Else
  91.                     .Image = "File"
  92.                 End If
  93.             End With
  94.             
  95.             colData.Add fsItem
  96.             
  97.         End If
  98.         
  99.     End If
  100.     strTemp = Dir
  101. Loop
  102.  
  103. End Sub
  104.  
  105.